home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-22 | 66.9 KB | 2,281 lines | [TEXT/MPS ] |
- /*
- File: Window.cpp
-
- Contains: Implementation of class ODWindow
-
- Owned by: Richard Rodseth
-
- Copyright: © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 3/15/96 VL 1302780: Added GetFacetUnderPointForDrag so
- that we can ignore selection when we try to
- find the facet under mouse point.
- <80> 10/18/95 JBS 1288922 in ::Update, move DrawActiveBorder
- to after EndUpdate
- <79> 10/17/95 jpa &RCR: 1292659: Catch/ignore part exceptions
- returned from handling activate/suspend
- events. 1289153: Don't crash if opening
- window fails.
- <78> 10/16/95 RR #1293067 Pass shouldDispose to
- RegisterWindow
- <77> 10/10/95 DM 1277216: GM:API: Dont return ODPoint from
- GetWindowPoint()
- <76> 10/8/95 TJ Fixes Recomended by Refball
- <75> 10/3/95 TJ Changes done by RefBall Team
- <74> 9/21/95 JBS 1284283 set _fRootFrame to NULL after
- Close-ing or Remove-ing it
- <73> 9/13/95 DM 1277216 GM:API return no ODPoints nor
- ODPolygons
- <72> 9/12/95 RR #1282498 Removed CanvasChanged call in
- Close() and CloseAndRemove(). #1280629
- Catch outofmemory error in ODDrawGrowIcon
- <71> 9/8/95 jpa Renumbered private err codes [1281354]
- <70> 9/8/95 TÇ 1281096 FB2:Many constants in ODTypesB
- without kOD prefix!
- <69> 9/6/95 RR #1236387 Don't draw active border in
- background
- <68> 9/1/95 RR # 1279100/1280338 Added fIsActive. Rewrote
- IsActive and Select
- <67> 8/29/95 RR #1267251 Pass synthesized activate events
- to Dispatcher #1278308 Remove THROW in
- SetStorageUnit
- <66> 8/26/95 TÇ 1274606 FB2: Patching Remarks
- <65> 8/21/95 RR #1246478 Disabled fDIrty optimization.
- #1243157 Changed GetFacetUnderPoint
- iteration order. #1273596 Set _fStorageUnit
- in InitWindowForFrame
- <64> 8/15/95 RR # 1264461/1262903 Added ODDrawGrowIcon.
- 1267238 Fixed ASSERT in InitWindow. 1263706
- Indentation.
- <63> 8/12/95 TÇ 1276807 Opt./Bug: use StdTypIO routines for
- portable streaming & smaller footprint,
- 1276806 Optimization: use kODFalse instead
- of kODTrue in comparisons
- <62> 8/3/95 RR #1257260: Collapse B classes. Remove
- somInit methods. Don't call IsInitialized
- or SubclassResponsibility
- <61> 7/26/95 DM #1270320: Memory leak fixes: delete
- rootCanvas in Close and CloseAndRemove
- <60> 6/30/95 RR 1242642 BB Ref counting fixes. Hide calls
- HideODWindow only if shown.
- <59> 6/28/95 RR 1242642 BB Mostly ref counting. Acquire and
- Release fDraft
- <58> 6/25/95 TÇ 1242642 BB: Turn on ODDebug warning if
- refcount is wrong in
- ODRefCntObjectsomUninit.
- <57> 6/23/95 JBS 1261323 Draft::CreateFrame: add isSubframe
- param, remove isRoot
- <56> 6/15/95 RR #1241680 Don't call somFree in InitWindow
- <55> 6/8/95 RR #1257260 Collapse base classes. #1214898
- StdTypes.r -> ODTypes.r
- <54> 5/31/95 RR #1251403 Release after AcquirePart
- <53> 5/30/95 CG #1252280 BB: PStrToIntl should not be used
- by OpenDoc.
- <52> 5/26/95 RR #1251403: Multithreading naming support
- <51> 5/25/95 jpa Fixed usage of ODDebug. [1253321]
- <50> 5/19/95 RR #1249981 Added (Set)ShouldDIspose #1251128
- WARN if shouldSave is set and root frame is
- non-persistent
- <49> 5/17/95 RR #1250135/1250137/1250143 Getters increment
- refcount. #1248624 Error updating window
- causes endless alerts
- <48> 5/10/95 JBS 1224727 Facet hit-testing calls should take
- point param in frame coords;1227547
- Coordinate system for ODWindow::Update and
- ODFacet::Update
- <47> 5/2/95 RR # 1244133 Fixed SetDefaultWindowTitles to
- avoid extra bogus characters. Also
- CloseAndRemove calls frame->Close if draft
- is readonly
- <46> 4/28/95 RR 1211085 Remove 5$ comments
- <45> 4/14/95 TÇ #1235279 BB: InfoUtil & StdTypIO functions
- should take Environment* and SU* when
- possible
- <44> 4/13/95 RR # 1216618 Added ODVolatile, use
- ODDeleteObject
- <43> 4/7/95 RR #1216618 Added SOM_TRY etc.
- <42> 4/6/95 RR #1211085 Remove 5$ comments
- <41> 4/4/95 RR # 1220228 Use Factory methods, #1211085
- SetSourceFrame ref counting
- <40> 3/31/95 TÇ 1223505 BB: Opening and creating documents
- on read only media. Fixed Creation of
- Non-persistent frames on readonly drafts.
- <39> 3/22/95 RR #1225420, 1227993 Added private
- InitWindowForFrame
- Removed InitWindowFromStorage
- Modified Externalize
- <38> 3/10/95 RR # 1220199 Externalize source frame
- properly. 1226379 Call ODNewRgn. Dispose
- growRgn.
- <37> 3/7/95 RR # 1220929 Added fSelectionFocus #1212490
- Added fInBackground
- <36> 3/1/95 RR #1205622 Support re-opening an open draft
- by making ::Open a no-op if the window is
- already open.
- <35> 2/28/95 VL 1194656: Commented out extraenous AddValue.
- <34> 2/24/95 jpa Use ODNewRgn. [1220810]
- <33> 2/22/95 RR # 1220228 Use factory methods
- <32> 2/20/95 TÇ #1221861 BB: Incomplete AOCE support needs
- to be removed from OpenDoc
- <31> 2/15/95 JBS 1198600 don't release rootFrame after
- close, private field fShouldAdjustOnOpen
- <30> 2/10/95 RR # 1218467 Refcount source frame. Remove
- root part field, and add root part
- parameter to CreateRootFrame
- <29> 1/26/95 eeh 1214080: OpenDoc really uses kODMacIText,
- not kODIntlText.
- <28> 1/26/95 VL #???: Use updated Storage Unit Ref API.
- <27> 1/13/95 RR Pass eventInfo to HandleEvent
- <26> 12/20/94 VL 1195012: Make Storage calls be
- marshallable.
- <25> 11/1/94 RR #1196759 Dispose of window pointer, unless
- it's the mailer (check was wrong)
- <24> 9/30/94 RR #1183610 Add and use fIsDirty
- <23> 9/29/94 eeh #1154961: remove local def of
- kODPropWindowMailerIsExpanded
- <22> 9/29/94 RA 1189812: Mods for 68K build.
- <21> 9/22/94 JBS 1188214: coordinate bias implementation
- <20> 9/22/94 eeh #1154961 'ternalize whether mailer was
- expanded; use this info in creating root
- facet.
- <19> 9/1/94 RR #1181184 Externalize bounds as ODRect and
- title as IText, and use StdTypIO routines,
- #1167957 Fixed GetProcID so that all window
- types are correctly ternalized, #115685
- Don't invalidate content region when
- resizing. Don't Erase when Updating.
- <18> 8/31/94 TÇ #1183129, #1183116, #1183119, #1183111:
- Lots of ErrorCode cleanup.
- <17> 8/29/94 RR #1156187,1171772,1178673,1183062,1171771
- <16> 8/26/94 VL 1183174: Use updated cloning APIs.
- <15> 8/19/94 TÇ #1180922 Need to Stop using obsolete types
- (kOD ID)
- <14> 8/15/94 JBS 1181138: add frameType to CreateFrame();
- 1181156: UI API Cleanup
- <13> 8/15/94 TÇ #1180922 Removed most obsolete types from
- StdTypes.idl
- <12> 8/15/94 VL #???: Added frameType (kODNULL) parameter
- to CreateFrame.
- <11> 8/12/94 JBS 1179919: add biasCanvas param to
- Draft::CreateFrame()
- <10> 8/12/94 JBS 1179920: move fWindow from Facet to Frame
- <9> 8/10/94 JBS 1179919: coordinate system bias changes
- <8> 8/4/94 eeh bug 1179054: in ODWindowIsActive check for
- null frontwindow
- <7> 8/3/94 VL 1153123: Storage to ODStor.
- <6> 7/27/94 eeh Changes necessitated by WinStat.idl changes
- <5> 7/26/94 eeh ODQDPoint->Point, no more lying to SOM
- <4> 7/21/94 eeh Rect param to FixUpMailerWindow -> Rect*
- <3> 7/5/94 VL Fixed parameters to CreateFrame.
- <2> 6/28/94 RR First conversion
- <1> 6/28/94 RR first checked in
- <0> 6/27/94 SV SOMverted
- <11> 4/6/94 JBS 1155477, 1155480
- <10> 3/28/94 CG 1153547: Renamed XMPSessn.h to XMPSessM.h
- <9> 3/25/94 JA Added missing #include (1147588)
- <8> 3/18/94 CC Include ConstDef.h to access kXMPAppleTEXT.
- (1151636)
- <7> 3/16/94 eeh bug #1149649: InitWindowFromStorage now
- calls MakeWindowIntoReply
- <6> 3/9/94 eeh bug #1146749: assign TRUE to isMailerAware
- by default for root windows
- <5> 2/22/94 RR #1145944 Call Release() as the last thing
- in CloseAndRemove().
- <4> 2/22/94 VL Release Window after fRootFrame is
- released.
- <3> 2/17/94 JBS #114???? fix inconsistent facet coords
- <2> 2/16/94 JA Include new AltPoint.h.
- <91> 2/7/94 NP Tiger Team doings.
- <90> 2/7/94 NP Tiger Team doings.
- <89> 2/7/94 JA Utility.h --> XMPUtils.h
- <88> 2/7/94 NP Tiger Team doings.
- <87> 2/3/94 CG Session reorg.
- <86> 2/2/94 RR Removed calls to SetRoot
- <85> 2/2/94 JBS new AddDisplayFrame recipie
- <84> 2/1/94 JA Removed use of obsolete typedef in
- CreateRootFrame.
- <83> 2/1/94 CC Added ShouldShowLinks(),
- SetShouldShowLinks(), and code to read &
- write the setting.
- <82> 1/28/94 RR macro for ASLM qd globals
- <81> 1/27/94 RR setwtitle->SetWTitle
- <80> 1/26/94 RR Call Dispatcher::InvalidateFacetUnderMouse
- <79> 1/25/94 RR Removed redundant fWindowWasVisible. Moved
- Release from WinState::RemoveWindow to
- ::Close. Open no longer calls Show.
- <78> 1/24/94 SS Update for new InitCanvas method
- <77> 1/24/94 eeh moved AOCEObj init to CommonInitWindow
- <76> 1/21/94 RR Added shouldSave to InitWindow
- <75> 1/19/94 RR Removed redundant methods for drawing
- active border
- <74> 1/18/94 RR Remove const from Drag. Use IsShown rather
- than AcquireWindowVisible
- <73> 1/15/94 VL Release fRootFrame after closing it.
- <72> 1/15/94 RR WinState.h -> WinStat.h, Dispatch.h ->
- Disptch.h
- <71> 1/14/94 RR Added utility GetWindowPoint (Private to UI
- subsystem)
- <70> 1/13/94 eeh integrated AOCEObj
- <69> 1/12/94 RR Added CloseAndRemove
- <68> 1/11/94 eeh made mailer menu heierarchical
- <67> 1/11/94 TÇ Init... changes
- <66> 1/10/94 RR Added SetWindowTitle
- <65> 12/22/93 RR Added Get/SetID
- <64> 12/21/93 VL Changed ODStorageUnit::GetValueSize to
- ODStorageUnit::GetSize.
- <63> 12/21/93 JBS InitFacet changes
- <62> 12/21/93 JBS fix constructor and CreateRootFrame to
- CreateFrame with viewType & presentation
- <61> 12/20/93 VL Made ODWindow a non-persistent object.
- <60> 12/17/93 VL Fixed warning on ULong to UChar.
- <59> 12/16/93 RR Respect IsSelected as well as IsFrozen.
- Call DisposeDialog if it's a dialog.
- <58> 12/15/93 JBS back pointer in facet not frame
- <57> 12/14/93 EL Use text instead of Str255.
- <56> 12/14/93 TÇ InitWindow changes. Internalize,
- Initialize went away.
- <55> 12/8/93 VL Used new WindowState names.
- <54> 12/6/93 RR Added SuspendResume
- <53> 12/2/93 RR Fixed bug in AcquireFrameUnderPoint
- <52> 12/1/93 VL Added floating window support. Changed code
- for Show, Hide, IsActive. Added Select and
- Drag. Made window invisible when it is
- first created.
- <51> 11/24/93 RR Moved CreateRootFrame to
- InitializePersistent
- <50> 11/23/93 JA Changed <MenuBar.h> to <MenuBar.xh>.
- <49> 11/18/93 JBS use activeFrame->AcquireWindow(ev), ensure
- fRootFrame-SetWindow(this)
- <48> 11/18/93 eeh added SetTempMailerWindow call to
- RemoveAECEMailer
- <47> 11/18/93 TÇ call inherited::InitializePersistent()
- ::Externalize()
- <46> 11/18/93 eeh changed Internalize, Resized and
- CreateRootFacet to open mailer docs
- correctly; added GetMailerOffset
- <45> 11/17/93 RR Added accessors for shouldSave
- <44> 11/15/93 eeh various tweaks to support saving and
- opening docs with mailer attached
- <43> 11/12/93 JBS use Facets
- <42> 11/1/93 VL Used Strong References.
- <41> 10/29/93 RR EnDisableCommand -> EnableCommand
- <40> 10/29/93 TÇ changed FixUpMailerWindow to use a Str255
- not a Str255* to pacify CFront
- <39> 10/27/93 RR AcquireFrameUnderPoint takes point in window
- coordinates
- <38> 10/27/93 eeh added kODPropWindowHasMailer property to
- in/externalize, changed AOCEMailerIsActive
- to AOCEMailerIsPresent, and added call to
- FixUpMailerWindow to allow opening mailer
- documents.
- <37> 10/25/93 RR Use kODStr255 for window title
- <36> 10/22/93 RR GetProcID returns a short, not a long.
- Removed unused variable
- <35> 10/21/93 RR Added floating, resizable and rootWindow
- properties and their accessors. Implemented
- Show and Hide. Externalize new properties.
- Hide window in Close. Create window
- invisible in Internalize. etc. etc.
- <34> 10/20/93 eeh fixed problems with menus on non-AOCE
- machines
- <33> 10/20/93 eeh Changes in UpdateMailerMenus() and
- elsewhere required by new menu stuff.
- <32> 10/14/93 RR Add source frame parameter to
- AddDisplayFrame call
- <31> 10/14/93 JA ODShape fu: No longer returns copies from
- GetPlatformShape. Deal w/it.
- <30> 10/12/93 eeh Made mailer property persistent, and other
- mailer changes.
- <29> 10/8/93 VL Added Release().
- <28> 10/7/93 RR Added fRootPart and added rootPart to
- constructor. Renamed CreateRootFrame
- ->CreateLayout
- <27> 10/7/93 eeh Added methods for AOCE mailer support.
- <26> 10/6/93 JA Use new fixed-point XMPPoint.
- <25> 10/5/93 TÇ added #ifdef SSREMOVEWORKAROUND until
- su-> Remove(ev,ev) is fixed
- <24> 10/4/93 RR Define persistent properties in
- InitializePersistent, and ASSERT their
- presence in Internalize/Externalize
- <23> 10/4/93 RR Internalize/Externalize all window
- properties
- <22> 9/30/93 TÇ check to make sure fLayout≠NIL before
- trying to Close() and Release() it
- <21> 9/29/93 TÇ with RCR, changed Close() to Close Layout
- <20> 9/29/93 VL Added InitializePersistent.
- <18> 9/23/93 TÇ fixed a minor bug, was deleting fLayout
- which is now a PstObj and responsibility of Draft
- <17> 9/22/93 RR Added Open() method
- <16> 9/21/93 PH Remove fDragInfo GetDragInfo
- De/RegisterDroppableFrame
- <15> 9/17/93 JBS change Frame::Draw() call - no canvas param
- <14> 9/16/93 JA Updated shape/transform calls.
- <13> 9/10/93 RR Copy prototype code over
- <12> 9/10/93 JBS remove fCanvas, GetCanvas(), ChangeCanvas()
- <11> 8/24/93 RR Got rid of some CFront warnings
- <10> 8/19/93 RR Temporary hacks for "Real" shell
- <9> 8/11/93 TÇ move type & property constants to StdProps
- & StdTypes
- <8> 8/4/93 SS Field name change for new drag mgr code
- <6> 7/9/93 Added some minimal implementation
- <5> 7/9/93 RCR Rename -> ODWindow
- <4> 6/23/93 RCR Deregister -> Unregister
- <3> 4/29/93 RCR Rename includes
- <2> 4/26/93 RCR Added missing Initialize/Purge
- <1> 4/9/93 RCR Initial skeleton
-
- To Do:
-
- In Progress:
-
- */
-
- #define ODWindow_Class_Source
-
-
-
- #ifndef _ALTPOINT_
- #include "AltPoint.h" // Use C++ savvy XMPPoint and XMPRect
- #endif
-
-
- #ifndef SOM_ODWindow_xih
- #define VARIABLE_MACROS
- #include <Window.xih>
- #endif
-
- #ifndef _PLFMDEF_
- #include "PlfmDef.h"
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef SOM_ODContainer_xh
- #include <ODCtr.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
-
- #ifndef SOM_ODFacetIterator_xh
- #include <FacetItr.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef _STDTYPIO_
- #include <StdTypIO.h>
- #endif
-
- #ifndef _ITEXT_
- #include "IText.h"
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h> // SysBeep etc.
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- #ifndef __OCESTANDARDMAIL__
- #include <OCEStandardMail.h>
- #endif
-
- #ifndef __OCEERRORS__
- #include <OCEErrors.h>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef _PASCLSTR_
- #include "PasclStr.h"
- #endif
-
- #ifndef _CONSTDEF_
- #include "ConstDef.h"
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef _ODDEBUG_
- #include "ODDebug.h"
- #endif
-
- #ifndef _DOCUTILS_
- #include <DocUtils.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _ISOSTR_
- #include "ISOStr.h"
- #endif
-
- #ifndef _DSPUTILM_
- #include "DspUtilM.h"
- #endif
-
- #pragma segment ODWindow
-
- #include "WindowB.cpp" // Platform-independent methods, if any
-
- #define ODDebugActivates 0
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- // Check ErrorDef.idl before adding any new codes here, to make sure they're unique.
- const ODError kODErrInvalidPlatformWindow = -29828;
- const ODError kODErrInvalidWindow = -29827;
-
- // TÇ: This error code was only being used in this file, and then only
- // for checking the _fPlatformWindow field of a window at the beginning of
- // methods. It didn't seem to have anything to do with the api.
- // That is why I made it private to this file.
- // perhaps the error that should be thrown is kODErrObjectNotInitialized?
- // kODErrInvalidWindow falls into the same category.
-
-
- //==============================================================================
- // Types
- //==============================================================================
-
- //=====================================================================================
- // ODWindow Methods
- //=====================================================================================
-
-
- //-------------------------------------------------------------------------------------
- // ODWindow: CommonInitWindow
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowCommonInitWindow(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","CommonInitWindow");
-
- SOM_TRY
-
- _fSession = (ODSession*) _fDraft->GetDocument(ev)->GetContainer(ev)->GetStorageSystem(ev)->GetSession(ev);
- _fArbitrator = _fSession->GetArbitrator(ev);
- _fSelectionFocus = _fSession->Tokenize(ev,kODSelectionFocus);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
-
- //-------------------------------------------------------------------------------------
- // ODWindow: InitWindow
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowInitWindow (ODWindow *somSelf, Environment *ev,
- ODPlatformWindow platformWindow,
- ODType frameType,
- ODBoolean isRootWindow,
- ODBoolean isResizable,
- ODBoolean isFloating,
- ODBoolean shouldSave,
- ODBoolean shouldDispose,
- ODPart* rootPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODFrame* sourceFrame)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","InitWindow");
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fPlatformWindow = kODNULL;
- _fRootFacet = kODNULL;
- _fSourceFrame = kODNULL;
- _fSession = kODNULL;
- _fIsRootWindow = kODTrue;
- _fShouldSave = kODTrue;
- _fIsResizable = kODFalse;
- _fIsFloating = kODFalse;
- _fWasVisible = kODFalse;
- _fShouldShowLinks = kODFalse;
- _fArbitrator = kODNULL;
-
- _fStorageUnit = kODNULL;
- _fIsDirty = kODFalse;
- _fDraft = kODNULL;
-
- _fShouldAdjustOnOpen = kODFalse;
- _fInBackground = kODFalse;
- _fIsActive = kODFalse;
- _fSelectionFocus = 0;
- */
- _fShouldDispose = shouldDispose;
-
- somSelf->InitRefCntObject(ev);
-
- #if ODDebug
- if (shouldSave && ODISOStrEqual(frameType, kODNonPersistentFrameObject))
- WARN("InitWindow: shouldSave is TRUE, but root frame is nonpersistent ");
-
- #endif
-
- _fPlatformWindow = platformWindow;
- _fIsRootWindow = isRootWindow;
- _fIsResizable = isResizable;
- _fIsFloating = isFloating;
- if (sourceFrame)
- sourceFrame->Acquire(ev);
- _fSourceFrame = sourceFrame;
- _fDraft = rootPart->GetStorageUnit(ev)->GetDraft(ev);
- _fDraft->Acquire(ev);
- if (!HAS_WRITE_ACCESS(_fDraft->GetPermissions(ev)))
- {
- shouldSave = kODFalse;
- frameType = kODNonPersistentFrameObject;
- }
-
- _fShouldSave = shouldSave;
-
- somSelf->CommonInitWindow(ev);
-
- somSelf->CreateRootFrame(ev, frameType, viewType, presentation, rootPart);
-
- _fIsDirty = kODTrue;
- _fShouldAdjustOnOpen = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
- //-------------------------------------------------------------------------------------
- // ODWindow: InitWindowForFrame
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowInitWindowForFrame (ODWindow *somSelf, Environment *ev,
- ODPlatformWindow platformWindow,
- ODFrame* frame,
- ODBoolean isRootWindow,
- ODBoolean isResizable,
- ODBoolean isFloating,
- ODBoolean shouldSave,
- ODBoolean shouldDispose,
- ODFrame* sourceFrame)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","InitWindow");
-
- SOM_TRY
-
- ASSERT(frame != kODNULL, kODErrInvalidFrame);
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fPlatformWindow = kODNULL;
- _fRootFacet = kODNULL;
- _fSourceFrame = kODNULL;
- _fSession = kODNULL;
- _fIsRootWindow = kODTrue;
- _fShouldSave = kODTrue;
- _fIsResizable = kODFalse;
- _fIsFloating = kODFalse;
- _fWasVisible = kODFalse;
- _fShouldShowLinks = kODFalse;
- _fArbitrator = kODNULL;
-
- _fStorageUnit = kODNULL;
- _fIsDirty = kODFalse;
- _fDraft = kODNULL;
-
- _fShouldAdjustOnOpen = kODFalse;
- _fInBackground = kODFalse;
- _fSelectionFocus = 0;
- */
- _fShouldDispose = shouldDispose;
-
- somSelf->InitRefCntObject(ev);
-
- #if ODDebug
- if (shouldSave && (frame->GetStorageUnit(ev) == kODNULL))
- WARN("InitWindowForFrame: shouldSave is TRUE, but root frame is nonpersistent ");
-
- #endif
-
- _fPlatformWindow = platformWindow;
- _fIsRootWindow = isRootWindow;
- _fIsResizable = isResizable;
- _fIsFloating = isFloating;
- if (sourceFrame)
- sourceFrame->Acquire(ev);
- _fSourceFrame = sourceFrame;
- {
- TempODPart part = frame->AcquirePart(ev);
- _fDraft = part->GetStorageUnit(ev)->GetDraft(ev);
- _fDraft->Acquire(ev);
- }
-
- if (!HAS_WRITE_ACCESS(_fDraft->GetPermissions(ev)))
- shouldSave = kODFalse;
-
- _fShouldSave = shouldSave;
-
- somSelf->CommonInitWindow(ev);
-
- if (frame)
- {
- frame->Acquire(ev);
- frame->SetWindow(ev, somSelf);
- }
- _fRootFrame = frame;
-
- _fIsDirty = kODFalse;
- _fShouldAdjustOnOpen = kODFalse;
-
- ODStorageUnit* frameSU = frame->GetStorageUnit(ev);
- if ((frameSU != kODNULL) && (_fDraft != kODNULL))
- {
- ODID windowPropsID = ODGetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef);
- if (windowPropsID != kODNULLID)
- {
- _fStorageUnit = _fDraft->AcquireStorageUnit(ev, windowPropsID);
- }
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Purge
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODSize SOMLINK ODWindowPurge(ODWindow *somSelf, Environment *ev,
- ODSize size)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Purge");
-
- ODSize purgeSize = 0;
-
- SOM_TRY
-
- purgeSize = parent_Purge(somSelf, ev, size);
-
- SOM_CATCH_ALL
- WARN("Error %ld trying to purge in ODWindowPurge",ErrorCode());
- SetErrorCode(kODNoError); // Eat the exception; Purge should not
- // propagate it because clients function
- // fine whether memory was purged or not.
- SOM_ENDTRY
-
- return purgeSize;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Release
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowRelease(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Release");
-
- SOM_TRY
-
- parent_Release(somSelf, ev);
- if (somSelf->GetRefCount(ev) == 0)
- _fSession->GetWindowState(ev)->ReleaseWindow(ev,somSelf);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: ~ODWindow
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowsomUninit (ODWindow *somSelf)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","somUninit");
-
- Environment* ev = somGetGlobalEnvironment();
- // • Get rid of our window
- if (_fPlatformWindow && _fShouldDispose)
- {
- if (((WindowRecord*)_fPlatformWindow)->windowKind == dialogKind)
- DisposeDialog(_fPlatformWindow);
- else
- DisposeWindow(_fPlatformWindow);
- _fPlatformWindow = kODNULL;
- }
-
- // Storage Unit must be released before draft
- ODSafeReleaseObject(_fStorageUnit);
- ODSafeReleaseObject(_fDraft);
- ODSafeReleaseObject(_fRootFrame);
- ODSafeReleaseObject(_fSourceFrame);
- } // SOMLINK ODWindowsomUninit
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetPlatformWindow
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODPlatformWindow SOMLINK ODWindowGetPlatformWindow(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetPlatformWindow");
-
- return _fPlatformWindow;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: AcquireSourceFrame
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODFrame* SOMLINK ODWindowAcquireSourceFrame(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","AcquireSourceFrame");
-
- SOM_TRY
-
- if (_fSourceFrame)
- _fSourceFrame->Acquire(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return _fSourceFrame;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetSourceFrame
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetSourceFrame(ODWindow *somSelf, Environment *ev,
- ODFrame* frame)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","AcquireSourceFrame");
-
- SOM_TRY
-
- if (frame)
- frame->Acquire(ev);
- if (_fSourceFrame)
- _fSourceFrame->Release(ev);
-
- _fSourceFrame = frame;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetRootFrame
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODFrame* SOMLINK ODWindowGetRootFrame(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetRootFrame");
-
- return _fRootFrame;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetRootFacet
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODFacet* SOMLINK ODWindowGetRootFacet(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetRootFacet");
-
- return _fRootFacet;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: CreateRootFrame
- // PRIVATE
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowCreateRootFrame(ODWindow *somSelf, Environment *ev,
- ODType frameType,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODPart* rootPart)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","CreateRootFrame");
-
- ODShape* newShape = kODNULL;ODVolatile(newShape);
-
- SOM_TRY
-
- if (_fPlatformWindow)
- {
- Rect frameShape = _fPlatformWindow->portRect;
-
- TRY
-
- newShape = new ODShape; // Can't Use factory method because no frame is available yet
- THROW_IF_NULL(newShape);
- newShape->InitShape(ev);
-
- CATCH_ALL
- ODDeleteObject(newShape); newShape = kODNULL; // must delete before InitShape returns
- RERAISE;
- ENDTRY
-
- TempODShape tempShape = newShape; // ensures it's released
-
- ODRect r = _fPlatformWindow->portRect;
- newShape->SetRectangle(ev,&r);
- _fRootFrame = _fDraft->CreateFrame(ev, frameType, (ODFrame*)kODNULL,
- newShape, (ODCanvas*)kODNULL,
- rootPart, viewType, presentation,
- kODFalse, // isSubframe
- kODFalse); // isOverlaid
- _fRootFrame->SetWindow(ev, somSelf);
-
- if (rootPart && _fSourceFrame)
- rootPart->AttachSourceFrame(ev, _fRootFrame, _fSourceFrame);
- }
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- } // CreateRootFrame()
-
- //-------------------------------------------------------------------------------------
- // ODWindow: CreateRootFacet
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowCreateRootFacet(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","CreateRootFacet");
-
- ODShape* frameShape = kODNULL;
- ODShape* clipShape = kODNULL;
-
- SOM_TRY
-
- frameShape = _fRootFrame->AcquireFrameShape(ev, kODNULL);
- clipShape = frameShape->Copy(ev);
- ODReleaseObject(ev, frameShape);
-
- ODTransform* externalTransform = _fRootFrame->CreateTransform(ev);
-
- ODWindowState* windowState = _fSession->GetWindowState(ev);
- ODCanvas* rootCanvas = windowState->CreateCanvas(ev, kODQuickDraw,
- (ODPlatformCanvas) _fPlatformWindow,
- kODTrue, // isDynamic
- kODFalse); // isOffscreen
-
- _fRootFacet = windowState->CreateFacet(ev, _fRootFrame, clipShape, externalTransform, rootCanvas, kODNULL);
- ODReleaseObject(ev, clipShape);
- ODReleaseObject(ev, externalTransform);
-
- _fRootFrame->FacetAdded(ev,_fRootFacet);
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: AdjustWindowShape
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowAdjustWindowShape (ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","AdjustWindowShape");
-
- SOM_TRY
-
- if (_fPlatformWindow)
- {
- Rect contentRect = _fPlatformWindow->portRect;
- Rect growRect = contentRect;
- growRect.left = growRect.right - 15;
- growRect.top = growRect.bottom - 15;
-
- RgnHandle contentRgn = ODNewRgn();
- RgnHandle growRgn = ODNewRgn();
- RectRgn(contentRgn,&contentRect);
- RectRgn(growRgn,&growRect);
-
- if (_fIsResizable)
- DiffRgn(contentRgn,growRgn,contentRgn);
- ODDisposeHandle((Handle)growRgn);
-
- SetPort(_fPlatformWindow);
- // InvalRgn(contentRgn);
-
- ODShape* windowShape =_fRootFrame->CreateShape(ev);
- windowShape->SetPlatformShape(ev,kODQuickDraw, (ODPlatformShape)contentRgn);
- #ifdef TO_BE_DELETED
- ODTransform* xform = _fRootFacet->AcquireExternalTransform(ev);
- windowShape->InverseTransform(ev, xform); // JBS - must transform frameShape to facet coords
- ODReleaseObject(ev, xform);
- #endif // TO_BE_DELETED
- ODShape* tempShape = kODNULL;
- tempShape = windowShape->Copy(ev);
- _fRootFacet->GetFrame(ev)->ChangeFrameShape(ev, windowShape, kODNULL);
- _fRootFacet->ChangeGeometry(ev, tempShape, kODNULL, kODNULL);
- ODReleaseObject(ev, windowShape);
- ODReleaseObject(ev, tempShape);
- }
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- } // AdjustWindowShape
-
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Open
- //
- // Description
- //-------------------------------------------------------------------------------------
-
-
- SOM_Scope void SOMLINK ODWindowOpen (ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Open");
-
- SOM_TRY
-
- if (_fRootFacet == kODNULL)
- {
- somSelf->CreateRootFacet(ev);
- if ( _fShouldAdjustOnOpen )
- somSelf->AdjustWindowShape(ev);
- _fIsDirty = kODTrue;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Close
- //
- // Description
- //-------------------------------------------------------------------------------------
-
-
- SOM_Scope void SOMLINK ODWindowClose(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Close");
-
- SOM_TRY
-
- somSelf->Hide(ev);
- _fSession->GetWindowState(ev)->RemoveWindow(ev,somSelf);
-
- if ( _fRootFrame )
- {
- if ( _fRootFacet )
- {
- _fRootFrame->FacetRemoved(ev,_fRootFacet);
- _fSession->GetDispatcher(ev)->InvalidateFacetUnderMouse(ev);
-
- ODCanvas* rootCanvas = _fRootFacet->GetCanvas(ev); // DMc - new
- ODDeleteObject(rootCanvas); // DMc - new
- ODDeleteObject(_fRootFacet);
- }
-
- _fRootFrame->Close(ev);
- _fRootFrame = kODNULL;
- }
-
- ODReleaseObject(ev, _fSourceFrame);
- _fIsDirty = kODTrue;
- somSelf->Release(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- } // Close()
-
- //-------------------------------------------------------------------------------------
- // ODWindow: CloseAndRemove
- //
- // Description
- //-------------------------------------------------------------------------------------
-
-
- SOM_Scope void SOMLINK ODWindowCloseAndRemove(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","CloseAndRemove");
-
- SOM_TRY
-
- if (_fPlatformWindow)
- {
- somSelf->Hide(ev);
- _fSession->GetWindowState(ev)->RemoveWindow(ev,somSelf);
-
- if ( _fRootFrame )
- {
- if ( _fRootFacet )
- {
- _fRootFrame->FacetRemoved(ev,_fRootFacet);
- _fSession->GetDispatcher(ev)->InvalidateFacetUnderMouse(ev);
-
- ODCanvas* rootCanvas = _fRootFacet->GetCanvas(ev); // DMc - new
- ODDeleteObject(rootCanvas); // DMc - new
- ODDeleteObject(_fRootFacet);
- }
-
- if (!HAS_WRITE_ACCESS(_fDraft->GetPermissions(ev)))
- {
- _fRootFrame->Close(ev);
- _fRootFrame = kODNULL;
- }
- else
- {
- _fRootFrame->Remove(ev);
- _fRootFrame = kODNULL;
- }
- }
-
- ODReleaseObject(ev, _fSourceFrame);
- somSelf->Release(ev);
- _fIsDirty = kODTrue;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- }
-
-
-
- //-------------------------------------------------------------------------------------
- // ODWindow: HandleActivateEvent
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- static void ODDrawGrowIcon(ODPlatformWindow window)
- {
- GrafPtr savePort;
-
- GetPort(&savePort);
- SetPort(window);
- Rect r = window->portRect;
- r.left = r.right - 15;
- r.top = r.bottom - 15;
- RgnHandle oldClip = kODNULL; ODVolatile(oldClip);
-
- TRY
- oldClip = ODNewRgn();
-
- GetClip(oldClip);
- ClipRect(&r);
- DrawGrowIcon(window);
- SetClip(oldClip);
-
- CATCH_ALL
- // Don't Reraise. Since this gets called when putting up
- // the low memory alert calls DeactivateFrontWindows #1280629
- ENDTRY
-
- ODDisposeHandle((Handle)oldClip);
- SetPort(savePort);
- }
-
- SOM_Scope void SOMLINK ODWindowHandleActivateEvent (ODWindow *somSelf, Environment *ev,
- ODEventData* theEvent)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","HandleActivateEvent");
-
- ODFrame* frame = kODNULL;
- ODFacetIterator* t = kODNULL; ODVolatile(t);
-
- SOM_TRY
-
- _fIsActive = (theEvent->modifiers & activeFlag == 1);
-
- t = _fRootFacet->CreateFacetIterator(ev,
- kODBottomUp, kODBackToFront);
-
- for (ODFacet* facet = t->First(ev); t->IsNotComplete(ev); facet = t->Next(ev))
- {
- if (facet)
- {
- TRY{
- frame = facet->GetFrame(ev);
- TempODPart part = frame->AcquirePart(ev); // -- TÇ tempobj'd
- if ((ODPart*)part)
- part->HandleEvent(ev,theEvent, frame, facet, kODNULL);
- }CATCH_ALL{
- // ignore exception
- }ENDTRY
- }
- }
- ODDeleteObject(t);
- if (somSelf->IsResizable(ev))
- ODDrawGrowIcon(_fPlatformWindow);
-
- SOM_CATCH_ALL
-
- ODDeleteObject(t);
-
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: HandleUpdateEvent
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowHandleUpdateEvent (ODWindow *somSelf, Environment *ev,
- ODEventData* theEvent)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","HandleUpdateEvent");
-
- ODUnused(theEvent);
-
- SOM_TRY
- somSelf->Update(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Update
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowUpdate(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Update");
-
- SOM_TRY
-
- if (_fPlatformWindow)
- {
- // #1248624 Failure handling should be further improved, but this should prevent
- // the infinite dialog problem
- TRY
- GrafPtr savePort;
-
- GetPort(&savePort);
- somSelf->PrepareCanvas(ev);
-
- TempODFrame activeFrame
- = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev,_fSelectionFocus);
- BeginUpdate(_fPlatformWindow); // this sets up the visRgn
-
- if (!EmptyRgn(_fPlatformWindow->visRgn)) // draw if updating needs to be done
- {
- // Let the part decide
- // EraseRgn (_fPlatformWindow->visRgn);
-
- {
- ODFacet* rootFacet = _fRootFacet;
-
- RgnHandle updateRgn = ODNewRgn();
- CopyRgn(_fPlatformWindow->visRgn, updateRgn);
- TempODShape updateShape = rootFacet->CreateShape(ev);
- updateShape->SetPlatformShape(ev,kODQuickDraw, updateRgn);
- TempODTransform xform = rootFacet->AcquireWindowFrameTransform(ev, kODNULL);
- updateShape->InverseTransform(ev, xform);
- rootFacet->Update(ev, updateShape, kODNULL);
- }
- // • Focus back on the window so that everything gets reset
- somSelf->PrepareCanvas(ev);
-
- // • After everything is back in shape we need to get the grow icon drawn
- if (somSelf->IsResizable(ev))
- ODDrawGrowIcon(_fPlatformWindow);
- }
- EndUpdate(_fPlatformWindow);
- somSelf->DrawActiveBorder(ev,activeFrame);
- SetPort(savePort);
-
- CATCH_ALL
- EndUpdate(_fPlatformWindow);
- ENDTRY
- }
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- } // SOMLINK ODWindowUpdate
-
- //-------------------------------------------------------------------------------------
- // ODWindow: DrawActiveBorder
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowDrawActiveBorder(ODWindow *somSelf, Environment *ev, ODFrame* frame)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","DrawActiveBorder");
-
- // !!! needs to draw border for all facets of active frame
- // Don't draw in background. Also need to invalidate
-
- SOM_TRY
-
- if ( !_fInBackground && frame && (frame != _fRootFrame) )
- {
- frame->DrawActiveBorder(ev);
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: PrepareCanvas
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowPrepareCanvas(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","PrepareCanvas");
-
- SOM_TRY
-
- if (_fPlatformWindow)
- {
- SetPort (_fPlatformWindow);
- SetOrigin(0,0);
- ClipRect (&_fPlatformWindow->portRect);
- }
- else
- ClipRect (&ODQDGlobals.thePort->portRect);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: IsResizable
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowIsResizable(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","IsResizable");
-
- return _fIsResizable;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: IsFloating
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowIsFloating(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","IsFloating");
-
- return _fIsFloating;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: IsRootWindow
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowIsRootWindow(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","IsRootWindow");
-
- return _fIsRootWindow;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: ShouldSave
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowShouldSave(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","ShouldSave");
-
- return _fShouldSave;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetShouldSave
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetShouldSave(ODWindow *somSelf, Environment *ev,
- ODBoolean shouldSave)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetShouldSave");
-
- _fShouldSave = shouldSave;
- _fIsDirty = kODTrue;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: ShouldShowLinks
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowShouldShowLinks(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","ShouldShowLinks");
-
- return _fShouldShowLinks;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetShouldShowLinks
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetShouldShowLinks(ODWindow *somSelf, Environment *ev,
- ODBoolean shouldShowLinks)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetShouldShowLinks");
-
- _fShouldShowLinks = shouldShowLinks;
- _fIsDirty = kODTrue;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: ShouldDispose
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowShouldDispose(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","ShouldDispose");
-
- return _fShouldDispose;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetFacetUnderPoint
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- typedef enum { kODForDragEvent, kODForMouseEvent } FacetSearchConstraint;
-
- ODFacet* GetFacetUnderPointInternal( Environment *ev, ODFacet* rootFacet,
- ODPoint* windowPoint, FacetSearchConstraint constraint );
-
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetFacetUnderPoint
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODFacet* SOMLINK ODWindowGetFacetUnderPointForDrag(ODWindow *somSelf,
- Environment *ev, ODPoint* windowPoint)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetFacetUnderPointForDrag");
-
- ODFacet* foundFacet = kODNULL;
-
- SOM_TRY
- foundFacet = GetFacetUnderPointInternal( ev, _fRootFacet, windowPoint,
- kODForDragEvent );
- SOM_ENDTRY
-
- return foundFacet;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetFacetUnderPoint
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODFacet* SOMLINK ODWindowGetFacetUnderPoint(ODWindow *somSelf,
- Environment *ev, ODPoint* windowPoint)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetFacetUnderPoint");
-
- ODFacet* foundFacet = kODNULL;
-
- SOM_TRY
- foundFacet = GetFacetUnderPointInternal( ev, _fRootFacet, windowPoint,
- kODForMouseEvent );
- SOM_ENDTRY
-
- return foundFacet;
- }
-
- //-------------------------------------------------------------------------------------
- // GetFacetUnderPointInternal
- //
- // Description
- // Utility function for the two GetFacetUnderPoint methods above.
- //-------------------------------------------------------------------------------------
- ODFacet* GetFacetUnderPointInternal( Environment *ev, ODFacet* rootFacet,
- ODPoint* windowPoint, FacetSearchConstraint constraint )
- {
- ODFacet* foundFacet = kODNULL;
- ODFacetIterator* t = kODNULL; ODVolatile(t);
- ODPoint framePoint;
-
- SOM_TRY
- //!!! Should use frameshape containment to prune search
- t = rootFacet->CreateFacetIterator(ev,
- kODTopDown, kODBackToFront);
-
- for ( ODFacet* facet = t->First(ev);
- t->IsNotComplete(ev);
- facet = t->Next(ev) )
- {
- // get windowPoint in frame coords for hit-testing
- { TempODTransform winToFrame = facet->AcquireWindowFrameTransform(ev, kODNULL);
- framePoint = *windowPoint;
- winToFrame->InvertPoint(ev, &framePoint);
- }
-
- if (facet->ContainsPoint(ev, &framePoint, kODNULL))
- {
- foundFacet = facet;
- #if 0 /* this is the old code */
- if (facet->GetFrame(ev)->IsFrozen(ev) || facet->IsSelected(ev))
- t->SkipChildren(ev);
- #else /* this is the new -- replaces above */
- if (facet->GetFrame(ev)->IsFrozen(ev))
- t->SkipChildren(ev);
- else if ( (constraint == kODForMouseEvent) && facet->IsSelected(ev))
- {
- t->SkipChildren(ev);
- }
- #endif
- }
- else
- t->SkipChildren(ev);
- }
- delete t;
-
- SOM_CATCH_ALL
-
- ODDeleteObject(t);
-
- SOM_ENDTRY
-
- return foundFacet;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: IsActive
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowIsActive(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","IsActive");
-
- ODBoolean isActive = _fIsActive && !_fInBackground;
-
- return isActive;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Show
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowShow(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Show");
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- if (!somSelf->IsShown(ev))
- _fSession->GetWindowState(ev)->ShowODWindow(ev,somSelf);
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Hide
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowHide(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Hide");
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- if (somSelf->IsShown(ev))
- {
- _fSession->GetWindowState(ev)->HideODWindow(ev,somSelf);
- _fIsDirty = kODTrue;
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SuspendResume
- //
- // Send event to each visible window
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSuspendResume(ODWindow *somSelf, Environment *ev,
- ODEventData* event)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SuspendResume");
-
-
- const short kResumeMask = 0x01; // High byte suspend/resume event
- ODFrame* frame = kODNULL;
- ODFacetIterator* t = kODNULL; ODVolatile(t);
-
- _fInBackground = (event->message & kResumeMask) == 0;
-
- SOM_TRY
-
- somSelf->PrepareCanvas(ev);
- if (somSelf->IsResizable(ev))
- ODDrawGrowIcon(_fPlatformWindow);
-
- t = _fRootFacet->CreateFacetIterator(ev,
- kODTopDown, kODFrontToBack);
-
- for (ODFacet* facet = t->First(ev); t->IsNotComplete(ev); facet = t->Next(ev))
- {
- if (facet)
- {
- TRY{
- frame = facet->GetFrame(ev);
- TempODPart part = frame->AcquirePart(ev); // -- TÇ tempobj'd
- if ((ODPart*)part)
- part->HandleEvent(ev,event, frame, facet, kODNULL);
- }CATCH_ALL{
- // ignore exception
- }ENDTRY
- }
- }
- ODDeleteObject(t);
-
-
- TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev,_fSelectionFocus);
- if (activeFrame)
- {
- if (_fInBackground)
- activeFrame->InvalidateActiveBorder(ev);
- else // Limitation of API: Can't call Invalidate twice, because shape gets released
- activeFrame->DrawActiveBorder(ev);
- }
-
-
-
- SOM_CATCH_ALL
-
- ODDeleteObject(t);
-
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Activate
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowActivate(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Activate");
-
- SOM_TRY
-
- // Floating window implementation relies on suppressing activate events
- // Part::HandleEvent expects them, so they're synthesize here.
- // They must be routed through the dispatcher, so they can be monitored/patched
- // The modifiers field is hacked to alert the dispatcher that this is
- // an OpenDoc-generated activate event.
-
- EventRecord event;
-
- SetActivateEvent(event, _fPlatformWindow, kODTrue);
-
- _fSession->GetDispatcher(ev)->Dispatch(ev, &event);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Deactivate
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowDeactivate(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Deactivate");
-
- SOM_TRY
-
- // Floating window implementation relies on suppressing activate events
- // Part::HandleEvent expects them, so they're synthesize here.
- // They must be routed through the dispatcher, so they can be monitored/patched
- // Bit 1 (starting from 0) of the modifiers field is set to alert the dispatcher
- // that this is an OpenDoc-generated activate event.
-
- EventRecord event;
-
- SetActivateEvent(event, _fPlatformWindow, kODFalse);
-
- _fSession->GetDispatcher(ev)->Dispatch(ev, &event);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Drag
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowDrag(ODWindow *somSelf, Environment *ev,
- Point* startPoint,
- Rect* draggingBounds)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Drag");
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- _fSession->GetWindowState(ev)->DragODWindow(ev,somSelf, startPoint, draggingBounds);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Select
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSelect(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Select");
-
- SOM_TRY
-
- if (_fInBackground)
- {
- ProcessSerialNumber current;
- OSErr err = GetCurrentProcess(¤t);
- if (err == noErr)
- SetFrontProcess(¤t);
- }
- _fSession->GetWindowState(ev)->SelectODWindow(ev,somSelf);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: IsShown
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowIsShown(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","IsShown");
-
- ODBoolean isShown = kODFalse;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- isShown = ((WindowRecord*)_fPlatformWindow)->visible;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return isShown;
- }
-
- //-------------------------------------------------------------------------------------
- // Protected methods
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowHasCloseBox(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","HasCloseBox");
-
- ODBoolean hasCloseBox = kODFalse;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL,kODErrInvalidPlatformWindow);
- hasCloseBox = ((WindowRecord*)_fPlatformWindow)->goAwayFlag;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return hasCloseBox;
- }
-
- SOM_Scope ODBoolean SOMLINK ODWindowHasZoomBox(ODWindow *somSelf, Environment *ev)
-
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","HasZoomBox");
-
- ODBoolean hasZoomBox = kODFalse;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
- hasZoomBox = ((WindowRecord*)_fPlatformWindow)->spareFlag;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return hasZoomBox;
- }
-
- SOM_Scope ODBoolean SOMLINK ODWindowHasGrowBox(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","HasGrowBox");
-
- ODBoolean hasGrowBox = kODFalse;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
- hasGrowBox = somSelf->IsResizable(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return hasGrowBox;
- }
-
- SOM_Scope ODSShort SOMLINK ODWindowGetProcID(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetProcID");
-
- short theID = 0;
- ResType theType;
- Str255 theName;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- GetResInfo(((WindowPeek)_fPlatformWindow)->windowDefProc, &theID, &theType, theName);
- short theVariant = GetWVariant(_fPlatformWindow);
- theID = theID*16 + theVariant;
- // return GetWVariant(_fPlatformWindow);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return theID;
-
- }
-
- SOM_Scope void SOMLINK ODWindowGetWindowBounds(ODWindow *somSelf, Environment *ev,
- Rect* bounds)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetWindowBounds");
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
-
- ODRgnHandle contRgn;
-
- contRgn = ((WindowRecord*)_fPlatformWindow)->contRgn;
- *bounds = (**contRgn).rgnBBox;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- SOM_Scope ODSLong SOMLINK ODWindowGetRefCon(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetRefCon");
-
- ODSLong refCon = 0;
-
- SOM_TRY
-
- ASSERT(_fPlatformWindow != kODNULL, kODErrInvalidPlatformWindow);
- refCon = ((WindowRecord*)_fPlatformWindow)->refCon;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return refCon;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetWindowTitle
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetWindowTitle(ODWindow *somSelf, Environment *ev,
- char* title)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetWindowTitle");
-
- Str255 titleCopy;
-
- strcpy( (char*) &(titleCopy[1]), title);
- titleCopy[0] = strlen(title);
-
- SOM_TRY
-
- SetWTitle(_fPlatformWindow, titleCopy);
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetWasVisible
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetWasVisible(ODWindow *somSelf, Environment *ev,
- ODBoolean wasVisible)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetWasVisible");
-
- _fWasVisible = wasVisible;
- _fIsDirty = kODTrue;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetWasVisible
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODWindowGetWasVisible(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetWasVisible");
-
- return _fWasVisible;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: Externalize
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowExternalize(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","Externalize");
-
- // #1246478 Removing fIsDirty optimization, because clients can call GetPlatformWindow
- // and change things.
- //if ( !_fIsDirty )
- // return;
-
- SOM_TRY
-
- // Should Title be an ODIText?
-
- ODStorageUnit* su = _fStorageUnit;
-
- // No need to do these ASSERTs because the StdTypIO routines make sure
- // the appropriate property and value exist. -TÇ
- /*
- ASSERT(su->Exists(ev,kODPropWindowRect, kODRect, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowTitle, kODMacIText, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowProcID, kODSShort, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowIsVisible, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowHasCloseBox, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowHasZoomBox, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowIsResizable, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowIsRootWindow, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowIsFloating, kODBoolean, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropWindowRefCon, kODSLong, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropRootFrame, kODStrongStorageUnitRef, 0), kODErrInvalidWindow);
- //ASSERT(su->Exists(ev,kODPropSourceFrame, kODStrongStorageUnitRef, 0), kODErrInvalidWindow);
- ASSERT(su->Exists(ev,kODPropShouldShowLinks, kODBoolean, 0), kODErrInvalidWindow);
- */
-
- // Externalize Window Manager properties
-
- // Externalize the bounds as a standard ODRect
-
- Rect r;
- somSelf->GetWindowBounds(ev,&r);
- ODRect odRect(r);
- ODSetRectProp(ev, su, kODPropWindowRect, kODRect, &odRect);
-
- // Externalize title as an IText
-
- Str255 title;
- GetWTitle(_fPlatformWindow, title);
-
- ODScriptCode script = FontToScript(GetAppFont());
- ODLangCode lang = GetScriptVariable(script, smScriptLang);
-
- ODIText* iText = CreateITextPString(script, lang, &title[0]);
- ODSetITextProp(ev, su, kODPropWindowTitle, kODMacIText, iText);
- DisposeIText(iText);
-
- ODSetSShortProp(ev, su, kODPropWindowProcID, kODSShort, somSelf->GetProcID(ev));
- ODSetBooleanProp(ev, su, kODPropWindowIsVisible, kODBoolean, somSelf->IsShown(ev));
- ODSetBooleanProp(ev, su, kODPropWindowHasCloseBox, kODBoolean, somSelf->HasCloseBox(ev));
- ODSetBooleanProp(ev, su, kODPropWindowHasZoomBox, kODBoolean, somSelf->HasZoomBox(ev));
- ODSetULongProp(ev, su, kODPropWindowRefCon, kODSLong, somSelf->GetRefCon(ev));
-
- // Other properties
-
- ODSetBooleanProp(ev, su, kODPropWindowIsResizable, kODBoolean, somSelf->IsResizable(ev));
- ODSetBooleanProp(ev, su, kODPropWindowIsFloating, kODBoolean, somSelf->IsFloating(ev));
- ODSetBooleanProp(ev, su, kODPropWindowIsRootWindow, kODBoolean, somSelf->IsRootWindow(ev));
-
- ODSetBooleanProp(ev, su, kODPropShouldShowLinks, kODBoolean, somSelf->ShouldShowLinks(ev));
-
- // root frame
-
- ODSetStrongSURefProp(ev, su, kODPropRootFrame, kODStrongStorageUnitRef, _fRootFrame->GetStorageUnit(ev)->GetID(ev));
-
- // Source Frame (this property is only written if the value is non-NULL)
-
- if (_fSourceFrame)
- {
- ODSetStrongSURefProp(ev, su, kODPropSourceFrame, kODStrongStorageUnitRef,
- _fSourceFrame->GetStorageUnit(ev)->GetID(ev));
- }
- else if (ODSUExistsThenFocus(ev, su ,kODPropSourceFrame, kODStrongStorageUnitRef))
- {
- su->Remove(ev);
- }
-
- // Annotate the root frame with the window properties
- ODStorageUnit* frameSU = _fRootFrame->GetStorageUnit(ev);
- ODSetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef,
- su->GetID(ev));
-
- _fIsDirty = kODFalse;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetID
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODID SOMLINK ODWindowGetID(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetID");
-
- return _fID;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetID
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetID(ODWindow *somSelf, Environment *ev,
- ODID windowID)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetID");
-
- _fID = windowID;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: AcquireStorageUnit
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODStorageUnit* SOMLINK ODWindowGetStorageUnit(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetStorageUnit");
-
- SOM_TRY
-
- if (_fStorageUnit != kODNULL)
- _fStorageUnit->Internalize(ev);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
-
- return _fStorageUnit;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: SetStorageUnit
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowSetStorageUnit(ODWindow *somSelf, Environment *ev, ODStorageUnit* su)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","SetStorageUnit");
-
- SOM_TRY
-
- _fStorageUnit = su;
- su->Acquire(ev);
-
- // These below calls are unnecessary because the StdTypIO routines make sure
- // the appropriate property and value exist. -TÇ
- /*
- ODSUAddPropValue(ev, kODPropWindowRect, kODRect);
- ODSUAddPropValue(ev, kODPropWindowTitle, kODMacIText);
- ODSUAddPropValue(ev, kODPropWindowProcID, kODSShort);
- ODSUAddPropValue(ev, kODPropWindowIsVisible, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowHasCloseBox, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowHasZoomBox, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowIsResizable, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowIsRootWindow, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowIsFloating, kODBoolean);
- ODSUAddPropValue(ev, kODPropWindowRefCon, kODSLong);
- ODSUAddPropValue(ev, kODPropRootFrame, kODStrongStorageUnitRef);
- ODSUAddPropValue(ev, kODPropShouldShowLinks, kODBoolean);
- */
-
- _fIsDirty = kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetDraft
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope ODDraft* SOMLINK ODWindowGetDraft(ODWindow *somSelf, Environment *ev)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetDraft");
-
- return _fDraft;
- }
-
- //-------------------------------------------------------------------------------------
- // ODWindow: GetWindowPoint
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODWindowGetWindowPoint(ODWindow *somSelf, Environment *ev,
- Point* globalPoint, ODPoint* windowPoint)
- {
- ODWindowData *somThis = ODWindowGetData(somSelf);
- ODWindowMethodDebug("ODWindow","GetWindowPoint");
-
- Point localCopy = *globalPoint;
-
- GrafPtr curPort;
- GetPort(&curPort);
- SetPort(_fPlatformWindow);
- SetOrigin(0,0);
- GlobalToLocal(&localCopy);
- SetPort(curPort);
- *windowPoint = (ODPoint)localCopy;
- }
-